<template>
    <div>
        <head1></head1>
        <div>
            <van-card :price="lst.tcount" :title="lst.name" :thumb="lst.url">
                <template #footer>
                    <van-button size="mini" @click="gm(lst.id)">购买</van-button>
                </template>
            </van-card>
        </div>
        <footer1></footer1>
    </div>
</template>

<script>
import head1 from '../components/head1.vue'
import footer1 from '../components/footer1.vue'
export default {
    components:{
        "head1":head1,
        "footer1":footer1
    },
    data() {
        return {
            lst:[],
            userid:localStorage.getItem("userid")
        }
    },
    methods:{
        getcart(){
            this.axios.get("/getcart?userid="+this.userid).then(res=>{
                this.lst = res.data.data
            })
        },
        gm(id){
            this.axios.post('/addorder',{"userid":this.userid,"courseid":id}).then(res=>{
                if(res.data.code == 200){
                    alert(res.data.msg)
                    this.$router.push('/order')
                }else{
                    alert(res.data.msg)
                }
            })
        }
    },
    mounted(){
        this.getcart()
    }

}
</script>

<style>